package com.itheima_06;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ServerTest1 {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10086);
        ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(
                5,
                20,
                30,
                TimeUnit.SECONDS,
                new ArrayBlockingQueue<>(20),
                Executors.defaultThreadFactory(),
                new ThreadPoolExecutor.AbortPolicy()
        );
        while (true) {
            Socket accept = ss.accept();
            MyThread my = new MyThread(accept);
            //Thread t = new Thread(my);
            threadPoolExecutor.submit(my);

        }
        //fos.close();
        //ss.close();

    }
}
